﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using Microsoft.Extensions.Configuration;

namespace AChance.Func
{
    public static class FunVar
    {
        public class DataPkg
        {
            protected Hashtable _inData = new Hashtable();

            protected string _outState = "";
            protected string _outMsg = "";
            protected List<string> _outMsgDetail = new List<string>();
            protected Hashtable _outData = new Hashtable();

            /// <summary>
            /// 传入数据
            /// </summary>
            public Hashtable InData
            {
                get { return _inData; }
                set { _inData = value; }
            }
            /// <summary>
            /// 传出状态
            /// </summary>
            public string OutState
            {
                get { return _outState; }
                set { _outState = value?.Trim() ?? ""; }
            }
            /// <summary>
            /// 传出信息
            /// </summary>
            public string OutMsg
            {
                get { return _outMsg; }
                set { _outMsg = value?.Trim() ?? ""; }
            }
            /// <summary>
            /// 传出信息详情
            /// </summary>
            public List<string> OutMsgDetail
            {
                get { return _outMsgDetail; }
                set { _outMsgDetail = value; }
            }
            /// <summary>
            /// 传出数据
            /// </summary>
            public Hashtable OutData
            {
                get { return _outData; }
                set { _outData = value; }
            }
            /// <summary>
            /// 清空所有数据
            /// </summary>
            public virtual void Clear()
            {
                ClearIn();
                ClearOut();
            }
            /// <summary>
            /// 清空所有传入数据
            /// </summary>
            public virtual void ClearIn()
            {
                InData = new Hashtable();
            }
            /// <summary>
            /// 清空所有传出数据
            /// </summary>
            public virtual void ClearOut()
            {
                OutState = "";
                OutMsg = "";
                OutMsgDetail = new List<string>();
                OutData = new Hashtable();
            }
        }
        public class AppSettings
        {
            public void Init(IConfiguration configuration) => configuration.Bind(this);
            public ConnectClass Connect { get; set; } = new ConnectClass();
            public RedisClass Redis { get; set; } = new RedisClass();
            public CorsClass Cors { get; set; } = new CorsClass();
            public ConsoleClass Console { get; set; } = new ConsoleClass();
            public ArgsClass Args { get; set; } = new ArgsClass();
            public class ConnectClass
            {
                public Dictionary<string, string> SqlStrings { get; set; }
                public Dictionary<string, string> FileStrings { get; set; }
            }
            public class RedisClass
            {
                public string Configuration { get; set; }
            }
            public class CorsClass
            {
                public string[] AllowOrigins { get; set; }
                public string[] AllowMethods { get; set; }
                public string[] AllowHeaders { get; set; }
            }
            public class ConsoleClass
            {
                public bool Visible { get; set; }
                public bool RecordTransExecInfo { get; set; }
            }
            public class ArgsClass
            {

            }
        }


    }
}
